<?php

namespace app\common\model;

/**
 * [Recharge  财务明细表]
 * @author [C。]
 * @return html
 */
class Draw extends Base
{
    protected $name = 'draw';
    /**
     * 根据搜索条件获取列表信息
     */
    public function getLists($map, $from=0, $size = 5)
    {
        $order = ['d.id' => 'desc'];
        $join = [
            ['app_manager m','m.id = d.manager_id'],
        ];
        $field = 'd.id,m.tel,d.drawamt,d.addtime,d.af_amt';
        $result =  $this->field($field)
            ->alias('d')
            ->join($join)
            ->where($map)
            ->limit($from, $size)
            ->order($order)
            ->select();

        return $result;
    }
    /**
     * 根据条件来获取列表的数据的总数
     * @param array $param
     */
    public function getCounts($map = []) {
        $join = [
            ['app_manager m','m.id = d.manager_id'],
        ];
        $result =  $this
            ->alias('d')
            ->join($join)
            ->where($map)
            ->count();

        return $result;
    }
    /**
     * 获取最大提现次数
     * @param array $param
     */
    public function getMaxnum($map,$field) {
        return $this->where($map)->max($field);
    }
}